package com.tanhua.manage.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.tanhua.manage.domain.Log;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface LogMapper extends BaseMapper<Log> {

    /**
     *次日留存用户数
     * @return
     */
    @Select("select count(*) from tb_log where log_time =#{yesterdayTime} and type ='0102'\n" +
            "and user_id in (\n" +
            "select user_id from tb_log where log_time =#{todayTime} and type ='0101'\n" +
            ")")
    Integer queryNumRetention1d(@Param("todayTime") String todayTime,@Param("yesterdayTime") String yesterdayTime);

    /**
     *登陆次数  新注册用户数
     * @return
     */
    @Select("select count(*) from tb_log where log_time =#{todayTime} and type =#{type}")
    Integer queryNumLoginRegistered(@Param("todayTime") String todayTime,@Param("type") String type);

    /**
     *活跃用户数
     * @return
     */
    @Select("select count(DISTINCT user_id) from tb_log where log_time =#{todayTime}")
    Integer queryNumActive(@Param("todayTime") String todayTime);

}
